<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>单例模式</title>
	
	</style>
</head>
<body>
	<h1>单例模式</h1>

	<script>
		class Person {
		  constructor() {
		  	if (Person.instance) return Person.instance
		  	Person.instance = this
		  	

		  	this.numbers = []


		  }
		  add(name) {
		  	this.numbers.push(name)
		  }
		}

		const jiating1 = new Person()
		const jiating2 = new Person()

		console.log(jiating1 === jiating2)
		jiating1.add('小丽')

		console.log('jiating2.numbers', jiating2.numbers)


	</script>
</body>
</html>



